import {TokenType} from "./TokenType";
import {Pos} from "../utils/Pos"

export class Token {
    tokenType: TokenType;
    value: Object;
    startPos: Pos;
    endPos: Pos;


    constructor(tokenType: TokenType, value: Object, startPos: Pos, endPos: Pos);


    constructor(tokenType: TokenType, value: Object, startPos: Pos, endPos: Pos) {
        this.tokenType = tokenType as TokenType;
        this.value = value as Object;
        this.startPos = startPos as Pos;
        this.endPos = endPos as Pos;
    }

    equals(o: Object) {
        const token = o as unknown as Token;
        return this.startPos === token.startPos && this.endPos === token.endPos;
    }

    toString() {
        return this.tokenType;
    }
}